<?php if (!defined('BASEPATH')) exit('Sorry, error.. :]');class Login extends Controller {
	function __construct()	{		parent::Controller();		$this->load->library('simplelogin');		$this->load->helper('url');		//print_r($this->session->userdata);	}
	function index()	{		if( $this->session->userdata('logged_in') ) {			redirect('/admin/');		} else {			$this->smartylib->display('admin/login.tpl');		}	}
	function signin() {		$this->load->library('validation');		$rules['username'] = "required";		$rules['password'] = "required";		$this->validation->set_rules($rules);		$fields['username'] = 'username';		$fields['password'] = 'password';
		$this->validation->set_fields($fields);		if ($this->validation->run() == false) {			redirect('/admin/login/');		} else {			if($this->simplelogin->login($this->input->post('username'), $this->input->post('password'))) {				redirect('/admin/');			} else {				redirect('/admin/login/');			}		}	}
	function signout() {		$this->simplelogin->logout();				redirect('/admin/login/');	}}
?>